package com.example.hdwx.myapplication.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.example.hdwx.myapplication.R;
import com.example.hdwx.myapplication.eneity.daydaycook_eneitys.Daydaycook_raiders_eneity;
import com.example.hdwx.myapplication.untils.ImageShow;

import java.util.List;

/**
 * Created by hdwx on 2017/2/14.
 */

public class Daydaycook_item2_adapter extends RecyclerView.Adapter<Daydaycook_item2_adapter.ViewHolder> {
    List<Daydaycook_raiders_eneity> list;
    Context context;
    Daydaycook_item2_adapter(List <Daydaycook_raiders_eneity>list,Context context){
        this.list=list;
        this.context=context;
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.daydaycook_item2_recycle_view,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        new ImageShow().image_show(context,list.get(position).getImg_url(),holder.imageView);
        holder.title.setText(list.get(position).getTitle());
        holder.description.setText(list.get(position).getDescription());
        if("false".equals(list.get(position).getDisplayAuthor())){
            holder.hide.setVisibility(View.GONE);
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class  ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        TextView title,description,hide;
        public ViewHolder(View itemView) {
            super(itemView);
            imageView= (ImageView) itemView.findViewById(R.id.daydaycook_item2_recycle_img);
            //图片变暗
            imageView.setColorFilter(Color.parseColor("#40000000"));
            title= (TextView) itemView.findViewById(R.id.daydaycook_item2_recycle_title);
            description= (TextView) itemView.findViewById(R.id.daydaycook_item2_recycle_description);
            hide= (TextView) itemView.findViewById(R.id.daydaycook_item2_recycle_hide);

        }
    }

}
